package com.ztk.threadbasic.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Callable02 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask futureTask = new FutureTask<>(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                System.out.println("callable开始");
                return 100;
            }
        });

        FutureTask<Integer> futureTask2 = new FutureTask<>(() -> {
            System.out.println("callable的lambda开始");
            Thread.sleep(2000);
            return 200;
        });

        Thread thread = new Thread(futureTask);
        thread.start();
        Object o = futureTask.get();
        System.out.println(o);

    }
}
